﻿@{
    ViewBag.Title = "会员管理";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {

                gridList();
    });


    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/MemberManage/Member/GetGridJsonYaJin",
            height: $(window).height() - 128,
            colModel: [
                { label: '主键', name: 'F_Id', hidden: true, key: true },
               { label: '账户', name: 'F_Account', width: 120, align: 'left' },
                { label: '姓名', name: 'F_RealName', width: 240, align: 'left' },
                { label: '手机', name: 'F_MobilePhone', width: 180, align: 'left' },
                {
                    label: "用户角色", name: "F_DutyId", width: 180, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == "3") {
                            return '<span class=\"label label-success\">代理商</span>';
                        }
                        else {
                            return '<span class=\"label label-default\">无效</span>';
                        }
                    }
                }, {
                    label: "押金", name: "F_ManagerId", width: 280, align: "center"
                }
            ],
            pager: "#gridPager",
            sortname: 'F_UserId desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() }
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "注册会员",
            url: "/MemberManage/Member/Form",
            width: "750px",
            height: "600px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({prompt:"注：退还押金后，该用户将会冻结，不能提现！",
            url: "/MemberManage/Member/DeleteYaJin",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }

    function btn_set(roleid) {
        var content = "";
        var rolename = "粉丝";
        switch (roleid) {
            case 1:
                rolename = "代言人";
                break;
            case 2:
                rolename = "合伙人";
                break;
            case 3:
                rolename = "代理商";
                break;
        }
        var id = $("#gridList").jqGridRowValue().F_Id;

        $(".jqgrow").each(function (index) {
            var tds = $(this).find("td");
            if (tds.eq(1).text() == id) {
                content = "确定将会员【" + tds.eq(3).text() + "】设置为<span style='color:red'>【" + rolename + "】</span>吗？";
                return;
            }
        });

        if (content != ""&&id!="") {
            $.modalConfirm(content, function (res) {
                if (res) {
                    $.submitForm({
                        url: "/MemberManage/Member/SetUserLevel",
                        param: { levelid: roleid, uid:  id},
                        success: function (json) {
                            $.currentWindow().$("#gridList").trigger("reloadGrid");
                        }
                    });
                }
            });
        }
    }

    function btn_details() {
        var rows = $("#gridList").jqGridRowValue();
        console.log(JSON.stringify(rows));
        if (rows != null) {
            var keyValue = rows.F_Id;
            $.modalOpen({
                id: "Details",
                title: "查看代理商信息",
                url: "/MemberManage/Member/Details?keyValue=" + keyValue,
                width: "800px",
                height: "450px",
                btn: null
            });
        } else {
            $.modalAlert("请先选择需要查看的代理商信息！", "error");
        }
    }
</script>

<div class="topPanel">

    <div class="toolbar">

        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        @*<div class="btn-group">
            <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>注册会员</a>
        </div>*@
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>退还押金</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
    </div>
    @*<div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="编号/姓名/手机" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>*@
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

